package com.triz.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.triz.common.annotation.Log;
import com.triz.common.core.controller.BaseController;
import com.triz.common.core.domain.AjaxResult;
import com.triz.common.enums.BusinessType;
import com.triz.business.domain.PainPoints;
import com.triz.business.service.IPainPointsService;
import com.triz.common.utils.poi.ExcelUtil;
import com.triz.common.core.page.TableDataInfo;

/**
 * 项目痛点Controller
 * 
 * @author hlk
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/business/points")
public class PainPointsController extends BaseController
{
    @Autowired
    private IPainPointsService painPointsService;

    /**
     * 查询项目痛点列表
     */
//    @PreAuthorize("@ss.hasPermi('business:points:list')")
    @GetMapping("/list")
    public TableDataInfo list(PainPoints painPoints)
    {
        startPage();
        List<PainPoints> list = painPointsService.selectPainPointsList(painPoints);
        return getDataTable(list);
    }

    /**
     * 导出项目痛点列表
     */
//    @PreAuthorize("@ss.hasPermi('business:points:export')")
    @Log(title = "项目痛点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PainPoints painPoints)
    {
        List<PainPoints> list = painPointsService.selectPainPointsList(painPoints);
        ExcelUtil<PainPoints> util = new ExcelUtil<PainPoints>(PainPoints.class);
        util.exportExcel(response, list, "项目痛点数据");
    }

    /**
     * 获取项目痛点详细信息
     */
//    @PreAuthorize("@ss.hasPermi('business:points:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(painPointsService.selectPainPointsById(id));
    }

    /**
     * 新增项目痛点
     */
//    @PreAuthorize("@ss.hasPermi('business:points:add')")
    @Log(title = "项目痛点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PainPoints painPoints)
    {
        painPoints.setCreateBy(getUsername());
        return toAjax(painPointsService.insertPainPoints(painPoints));
    }

    /**
     * 修改项目痛点
     */
//    @PreAuthorize("@ss.hasPermi('business:points:edit')")
    @Log(title = "项目痛点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PainPoints painPoints)
    {
        painPoints.setUpdateBy(getUsername());
        return toAjax(painPointsService.updatePainPoints(painPoints));
    }

    /**
     * 删除项目痛点
     */
//    @PreAuthorize("@ss.hasPermi('business:points:remove')")
    @Log(title = "项目痛点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(painPointsService.deletePainPointsByIds(ids));
    }



}
